package cn.com.gridinfo.sooc.utils;

import com.jeremy.arad.utils.StringUtils;

/**
 * Created by michelle on 2016/4/11.
 */
public class TypeConvert {

    public static int stringToInt(String str) {
        try {
            if (!StringUtils.isNull(str)) {
                return Integer.parseInt(str);
            } else {
                return 0;
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return 0;
        }
    }

    public static int objectToInt(Object obj) {
        try {
            return stringToInt(objectToString(obj));
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return 0;
        }
    }

    public static String objectToString(Object obj){
        try {
            return String.valueOf(obj);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return "";
        }
    }

    public static int floatToInt(float ft){
        return (int)ft;
    }


}
